/****************************************************************************/
/* File: scs-alarm.cpp                                                      */
/* Desc: Implementation file for the core error codes                       */
/* Created: 2014-11-13                                                      */
/* Revised: 2014-11-14                                                      */
/* Authors: Sterling P. de Mille                                            */
/****************************************************************************/

#include "scs-error.h"

SCSerror scsErrorType (SCSerror iError) { return (iError & 0xff000000); }
SCSerror scsErrorMethod (SCSerror iError) { return (iError & 0x00ff0000); }
SCSerror scsErrorItem (SCSerror iError) { return (iError & 0x0000ff00); }
SCSerror scsErrorMessage (SCSerror iError) { return (iError & 0x000000ff); }

SCSstring scsErrorTypeString (SCSerror iError)
{
	switch (iError) {
	case SCS_ERROR_NONE: return "no error";
	case SCS_ERROR_TYPES: return "data type";
	case SCS_ERROR_CLOCK: return "clock";
	case SCS_ERROR_APPLICATION: return "application";
	case SCS_ERROR_VIDEO: return "video";
	case SCS_ERROR_INPUT: return "input";
	case SCS_ERROR_AUDIO: return "audio";
	case SCS_ERROR_NETWORK: return "network";
	case SCS_ERROR_MATH: return "math";
	case SCS_ERROR_PHYSICS: return "physics";
	default: return "unknown type";
	}
}
SCSstring scsErrorMethodString (SCSerror iError)
{
	switch (iError) {
	case SCS_ERROR_NONE: return "none";
	case SCS_ERROR_SET: return "set";
	case SCS_ERROR_GET: return "get";
	case SCS_ERROR_CREATE: return "create";
	case SCS_ERROR_DESTROY: return "destroy";
	case SCS_ERROR_LOAD: return "load";
	case SCS_ERROR_SAVE: return "save";
	case SCS_ERROR_INIT: return "init";
	case SCS_ERROR_BEGIN: return "begin";
	case SCS_ERROR_END: return "end";
	case SCS_ERROR_DRAW: return "draw";
	case SCS_ERROR_PLAY: return "play";
	case SCS_ERROR_STOP: return "stop";
	case SCS_ERROR_OPEN: return "open";
	case SCS_ERROR_CLOSE: return "close";
	default: return "unknown method";
	}
}
SCSstring scsErrorItemString (SCSerror iError)
{
	switch (iError) {
	case SCS_ERROR_MODE: return "mode";
	case SCS_ERROR_FLAG: return "flag";
	case SCS_ERROR_PRIMITIVE: return "primitive";
	case SCS_ERROR_IMAGE: return "image";
	case SCS_ERROR_SOUND: return "sound";
	case SCS_ERROR_MUSIC: return "music";
	case SCS_ERROR_KEYBOARD: return "keyboard";
	case SCS_ERROR_MOUSE: return "mouse";
	case SCS_ERROR_CONTROLLER: return "controller";
	case SCS_ERROR_DEVICE: return "device";
	default: return "unknown item";
	}
}
SCSstring scsErrorMessageString (SCSerror iError)
{
	switch (iError) {
	case SCS_ERROR_NULL: return "null";
	case SCS_ERROR_NOTSUPPORTED: return "not supported";
	case SCS_ERROR_INVALID: return "invalid";
	default: return "unknown message";
	}
}
SCSstring scsErrorString (SCSerror iError)
{
	return scsErrorTypeString(scsErrorType(iError)) + ": " +
		scsErrorMethodString(scsErrorMethod(iError)) + " - " +
		scsErrorItemString(scsErrorItem(iError)) + " - " +
		scsErrorMessageString(scsErrorMessage(iError));
}
